from rest_framework.views import APIView
from rest_framework.response import Response

from main.utils.util_json import get_json_from_file



class RoutesView(APIView):
    def post(self, request):
        roles = request.data
        print(roles)
        routes = get_json_from_file('data/routers.json')
        res_routes = routes.get('normal')
        # 获取路由信息
        if 'admin' in roles:
            res_routes = routes.get('admin') + res_routes
        return Response({'code':20000, 'data':res_routes})